package top.jingles.sayhiintime;

import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import java.io.PrintStream;

public class CheckTimeService
  extends Service
{
  private static CheckTimeService myInstance;
  private CheckTimeListener myThread;
  
  public CheckTimeService()
  {
    myInstance = this;
    System.out.println("service init");
  }
  
  public static CheckTimeService getInstance()
  {
    if (myInstance == null) {
      myInstance = new CheckTimeService();
    }
    System.out.println("service get instance");
    return myInstance;
  }
  
  public IBinder onBind(Intent intent)
  {
    return null;
  }
  
  public void onCreate()
  {
    super.onCreate();
    this.myThread = new CheckTimeListener();
    System.out.println("service create");
    this.myThread.execute(new Void[0]);
  }
  
  public void onDestroy()
  {
    System.out.println("service destroy");
    this.myThread.setStoped(true);
    super.onDestroy();
  }
  
  public void onStart(Intent intent, int paramInt)
  {
    super.onStart(intent, paramInt);
    System.out.println("service start");
    showNotify();
  }
  
  public void showNotify()
  {
    showNotify("燕姿说：", "好好工作呀~要注意休息呀~");
  }
  
  public void showNotify(String msgTitle, String msgContent)
  {
    System.out.println("service show notify");
    NotifyTask notifyTask = new NotifyTask(getApplicationContext(), this,
            (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE));
    notifyTask.setMsgInfo(msgTitle, msgContent);
    notifyTask.execute(new Void[0]);
  }
}
